import 'dart:async';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';
import 'package:stop_watch_timer/stop_watch_timer.dart';
import 'package:yp/config/index.dart';
import 'package:yp/helper.dart';
import 'package:yp/pages/mall_app/surplus_market/sm_details/logic.dart';
import 'package:yp/pages/mall_app/surplus_market/sm_details/state.dart';
import 'package:yp/router.dart';
import 'package:yp/utils/util.dart';
import 'package:yp/widgets/index.dart';

class SMDetailsPage extends StatefulWidget {
  SMDetailsPage({Key key}) : super(key: key);

  @override
  _SMDetailsPageState createState() => _SMDetailsPageState();
}

class _SMDetailsPageState extends State<SMDetailsPage> {
  GlobalKey _richContentLayoutKey = GlobalKey();
  final Color white = const Color(0xffffffff);
  final logic = Get.put(SMDetailsLogic());
  final state = Get.find<SMDetailsLogic>().state;
  bool _kIsWeb = kIsWeb;
  Timer surplusTimer;
  StateSetter _reloadTextSetter;
  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: SMDetailsLogic(),
        builder: (logic) {
          final SMDetailsState state = logic.state;
          Size size = MediaQuery.of(context).size;
          return Scaffold(
            appBar: YPNavigationBar(
              '拼团详情',
              backBtnColor: white,
              backgroundColor: EsColors.Primary,
              titleColor: white,
              actions: <Widget>[
                IconButton(
                    icon: Icon(Icons.share),
                    color: Colors.white70,
                    onPressed: () {
                      logic.shareToFriend();
                    }) ,
              ],
            ),
            body: Container(
              color: const Color(0xfff5f5f5),
              height: size.height,
              child: Stack(
                children: [
                  SingleChildScrollView(
                    child: Column(
                      children: [
                        /// 图片
                        state.details['image_default_id'] != null
                            ? Container(
                                width: size.width,
                                height: size.width,
                                color: const Color(0xffffffff),
                                child: Swiper(
                                  itemBuilder:
                                      (BuildContext context, int index) {
                                    return CachedNetworkImage(
                                      imageUrl:
                                          state.details['image_default_id'],
                                      errorWidget: (context, url, error) =>
                                          Icon(Icons.error),
                                      fit: BoxFit.fill,
                                    );
                                  },
                                  itemCount: 1,
                                  viewportFraction: 1,
                                  scale: 1,
                                  pagination: SwiperPagination(),
                                  // autoplay: true,
                                ),
                              )
                            : SizedBox(),

                        /// 倒计时
                        Container(
                          decoration: BoxDecoration(
                            gradient: LinearGradient(colors: const [
                              Color(0xff3C2F2E),
                              Color(0xff241715)
                            ]),
                          ),
                          padding: const EdgeInsets.symmetric(
                              vertical: 13, horizontal: 12),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Row(
                                crossAxisAlignment: CrossAxisAlignment.end,
                                children: [
                                  Padding(
                                    padding: const EdgeInsets.only(bottom: 6),
                                    child: Text(
                                      '￥',
                                      style:
                                          TextStyle(color: white, fontSize: 12),
                                    ),
                                  ),
                                  Text(
                                    toConstraintLen(
                                        state.details['depreciate'], 3),
                                    style: TextStyle(
                                      color: white,
                                      fontSize: 40,
                                      // fontWeight: FontWeight.bold,
                                    ),
                                  ),
                                ],
                              ),
                              Expanded(
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Container(
                                      decoration: BoxDecoration(
                                        color: white,
                                        borderRadius: BorderRadius.circular(15),
                                      ),
                                      margin: const EdgeInsets.only(left: 3),
                                      padding: const EdgeInsets.only(
                                          left: 7, right: 7, bottom: 1),
                                      child: Text(
                                        '${state.details['current_user_count'] ?? 0}人已参团',
                                        style: TextStyle(fontSize: 12),
                                      ),
                                    ),
                                    Column(
                                      children: [

                                        Text(
                                          '距结束',
                                          style: TextStyle(
                                              color: const Color(0xffC99F4F),
                                              fontSize: 13),
                                        ),
                                        getStopWatchTimer(),
                                        // StatefulBuilder(builder: (BuildContext context, StateSetter stateSetter){
                                        //   _reloadTextSetter = stateSetter;
                                        //   return Text(
                                        //     state.countContent,
                                        //     style: TextStyle(
                                        //       color: const Color(0xffC99F4F),
                                        //     ),
                                        //   );
                                        // },),
                                        // Text(
                                        //   state.countContent,
                                        //   style: TextStyle(
                                        //     color: const Color(0xffC99F4F),
                                        //   ),
                                        // ),
                                      ],
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),

                        Container(
                          color: white,
                          padding: const EdgeInsets.symmetric(
                              vertical: 20, horizontal: 12),
                          alignment: Alignment.centerLeft,
                          margin: const EdgeInsets.only(bottom: 10),
                          child: Text(
                            state.details['item_name'] ?? '',
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(fontSize: 16),
                          ),
                        ),
                        /// 玩法
                        _playRulesWidget(),
                        _divider(10),
                        _playRulesjtjWidget(),
                        _divider(10),
                        shopInfoWidget(), // 店铺查看
                        _divider(10),
                        _recommendGoodsModule(), // 推荐商品
                        _divider(10),
                        richTextDetailLayout(), // 图文详情
                        _divider(60),
                      ],
                    ),
                  ),
                  Positioned(
                    bottom: 0,
                    width: size.width,
                    height: 50,
                    child: Container(
                      decoration: BoxDecoration(
                        color: white,
                        border: Border(
                          top: BorderSide(color: const Color(0xffefefef)),
                        ),
                      ),
                      child: Row(
                        children: [
                          state.details['buy']!=true?Container():Expanded(
                            child: InkWell(
                              onTap: () {
                                logic.goShop();
                              },
                              child: Container(
                                alignment: Alignment.center,
                                child: Text(
                                  '直接购买￥${toConstraintLen(state.details['original_cost'], 3)}',
                                  textAlign: TextAlign.center,
                                  style: TextStyle(fontSize: 16),
                                ),
                              ),
                            ),
                          ),
                          state.details['buy']!=true?
                          Expanded(
                            child: Container(
                              color: const Color(0xffCCCCCC),
                              alignment: Alignment.center,
                              child: Text(
                                '已售空',
                                textAlign: TextAlign.center,
                                style:
                                    TextStyle(fontSize: 17, color: white),
                              ),
                            ),
                          ):
                          state.details['super_group_item_user_is_buy'] == 1
                              ? Expanded(
                                  child: Container(
                                    color: EsColors.Primary,
                                    alignment: Alignment.center,
                                    child: Text(
                                      '已参团',
                                      textAlign: TextAlign.center,
                                      style:
                                          TextStyle(fontSize: 17, color: white),
                                    ),
                                  ),
                                )
                              : Expanded(
                                  child: InkWell(
                                    onTap: () {
                                      if (state.details['buy']!=true) {
                                        return;
                                      }
                                      logic.goSurplusShop();
                                    },
                                    child: Container(
                                      color: EsColors.Primary,
                                      alignment: Alignment.center,
                                      child: Text(
                                        '参加超级团￥${toConstraintLen(state.details['depreciate'], 3)}',
                                        textAlign: TextAlign.center,
                                        style: TextStyle(
                                            fontSize: 17, color: white),
                                      ),
                                    ),
                                  ),
                                ),
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ),
          );
        });
  }

  Widget getStopWatchTimer(){
   return Container(
      child: StreamBuilder<int>(
          stream: state.smWatchTimer.rawTime,
          initialData: 0,
          builder: (context, snap) {
            final value = snap.data;
            return Text('${constructTime(value/1000)}',
              maxLines: 1,
              style: TextStyle(
                color: const Color(0xffC99F4F),
              ),
            );
          }
      ),

    );
  }
  Widget _rules({String data, String index}) {
    return Row(
      children: [
        Container(
          padding: const EdgeInsets.all(3),
          decoration: BoxDecoration(
            shape: BoxShape.circle,
            border: Border.all(),
          ),
          child: Text(index),
        ),
        SizedBox(width: 2),
        Text(
          data,
          style: TextStyle(height: 1.3),
        )
      ],
    );
  }

  Widget shopInfoWidget() {
    return state.shopInfos != null
        ? Container(
            color: const Color(0xffffffff),
            padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15),
            child: InkWell(
              onTap: () {
                if (_kIsWeb) return;
                logic.goToThirdShop();
              },
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                      margin: const EdgeInsets.only(right: 10),
                      width: setWidth(100),
                      height: setWidth(100),
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        color: const Color(0xfff4f4f4),
                        boxShadow: [
                          BoxShadow(
                            color: Colors.black12,
                            blurRadius: 2,
                          ),
                        ],
                      ),
                      child: Image.network(
                          state.shopInfos['ec_shop_logo'] == null ||
                                  state.shopInfos['ec_shop_logo'] == ''
                              ? Config.orderEmpty
                              : state.shopInfos['ec_shop_logo'])),
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Row(
                          children: [
                            Expanded(
                              child: Text(
                                state.shopInfos['shop_name'] ?? '',
                                overflow: TextOverflow.ellipsis,
                                style: TextStyle(
                                  color: const Color(0xff333333),
                                  fontWeight: FontWeight.bold,
                                  fontSize: 15,
                                ),
                              ),
                            ),
                            _kIsWeb
                                ? SizedBox()
                                : Padding(
                                    padding: const EdgeInsets.only(right: 13),
                                    child: Image.asset(
                                      'assets/images/arrow_right.png',
                                      width: 20,
                                      height: 20,
                                    ),
                                  ),
                          ],
                        ),
                        SizedBox(height: 5),
                        _kIsWeb
                            ? SizedBox()
                            : Container(
                                decoration: BoxDecoration(
                                  border: Border.all(
                                    color: const Color(0xffCCCCCC),
                                  ),
                                  borderRadius: BorderRadius.circular(20),
                                ),
                                padding:
                                    const EdgeInsets.only(top: 3, bottom: 3),
                                width: 110,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Container(
                                      width: 12,
                                      margin: const EdgeInsets.only(right: 6),
                                      child: Image.asset(
                                        'assets/images/shopLogo.png',
                                        fit: BoxFit.fill,
                                      ),
                                    ),
                                    Text(
                                      '进店逛逛',
                                      style: TextStyle(
                                        color: const Color(0xff333333),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          )
        : SizedBox();
  }

  //分隔控件
  Widget _divider(double height) {
    return Container(
      width: double.infinity,
      height: height,
      color: const Color(0xFFF3F4F6),
    );
  }

  // 推荐商品
  Widget _recommendGoodsModule() {
    if (state.recommendGoods == null || state.recommendGoods['lists'] == null) {
      return Container();
    }
    List list = state.recommendGoods['lists'];
    if (list == null || list.isEmpty) {
      return Container();
    }
    return Container(
      width: MediaQuery.of(context).size.width,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            padding: const EdgeInsets.only(left: 5, right: 5),
            height: 200,
            child: ListView.builder(
              shrinkWrap: true,
              scrollDirection: Axis.horizontal,
              itemCount: list.length,
              itemBuilder: (context, index) {
                return _recommendGoodsItem(list[index]);
              },
            ),
          ),
        ],
      ),
    );
  }

  // 推荐商品 item
  Widget _recommendGoodsItem(var goods) {
    String imgUrl = goods['image_default_id'];
    String goodsName = goods['title'];
    String price1 = goods['price'].toString();
    String price2 = goods['mkt_price'].toString();
    bool soldOutBool = goods['style_store'] <= 0;

    return InkWell(
      onTap: () {
        print('！！！！！！！！！！  商品点击事件  ！！！！！！！！！！');
        print('goods = $goods');
        print('！！！！！！！！！！  商品点击事件  ！！！！！！！！！！');

        String itemNumId = goods['default_item_num_id']?.toString() ?? '';
        String styleNumId = goods['style_num_id']?.toString() ?? '';
        String shopId = goods['shop_num_id']?.toString() ?? '';
        String cat1Id = goods['cat1_id']?.toString() ?? '';
        String ecStyleNumId = goods['ec_style_num_id'].toString() ?? '';
        print('商品点击事件'
            'itemNumId = $itemNumId'
            'styleNumId = $styleNumId'
            'shopId = $shopId'
            'cat1Id = $cat1Id'
            'ecStyleNumId = $ecStyleNumId');

        Get.back();
        Get.toNamed(RouteConfig.goodsDetail, arguments: {
          'itemNumId': itemNumId,
          'styleNumId': styleNumId,
          'shopId': shopId,
          'cat1Id': cat1Id,
          'ecStyleNumId': ecStyleNumId,
          'typeIndex': goods['is_pre_sale'],
        });
      },
      child: Container(
        width: 120,
        padding: const EdgeInsets.symmetric(horizontal: 5),
        child: Column(
          children: [
            Stack(
              children: [
                CachedImage(
                  width: 110,
                  height: 110,
                  margin: EdgeInsets.zero,
                  scale: BoxFit.fill,
                  path: imgUrl,
                ),
                Positioned(
                  left: 25,
                  top: 25,
                  child: soldOutBool
                      ? Container(
                          width: 60,
                          height: 60,
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                            color: Color(0xffbbbbbb).withOpacity(0.7),
                            borderRadius: BorderRadius.circular(setWidth(60)),
                          ),
                          child: Text(
                            '售罄',
                            style: TextStyle(
                              color: Colors.white,
                              fontSize: 15,
                            ),
                          ),
                        )
                      : SizedBox(),
                ),
              ],
            ),
            Padding(
              padding: const EdgeInsets.only(top: 10),
              child: Text(
                goodsName,
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(fontSize: 12, color: Colors.black),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(top: 8),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Expanded(
                    child: Padding(
                      padding: const EdgeInsets.only(right: 8.0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          RichText(
                              text: TextSpan(children: [
                            TextSpan(
                                text: '¥',
                                style: TextStyle(
                                  fontSize: 12,
                                  color: Config.mainColor,
                                )),
                            TextSpan(
                                text: price1,
                                style: TextStyle(
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold,
                                  color: Config.mainColor,
                                )),
                          ])),
                          Text(
                            price2,
                            style: TextStyle(
                              fontSize: 12,
                              color: const Color(0xFFCCCCCC),
                              decoration: TextDecoration.lineThrough,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  _kIsWeb || goods['fresh_type'] == 8
                      ? SizedBox()
                      : GestureDetector(
                          onTap: () {
                            if (SpUtil.getString('token') == null ||
                                SpUtil.getString('token').isEmpty) {
                              Get.toNamed(RouteConfig.mallLogin, arguments: {
                                'itemNumId': logic.itemNumId,
                                'styleNumId': logic.styleNumId,
                                'shopId': logic.shopId,
                                // 'typeIndex': state.typeIndex,
                              }).then((value) {
                                if (SpUtil.getString('token') != null &&
                                    SpUtil.getString('token').isNotEmpty) {
                                  // logic.requestDetail();
                                }
                              });
                            } else {
                              if (!soldOutBool) {
                                String ecShopNumId =
                                    goods['shop_num_id']?.toString() ??
                                        SpUtil.getObject(
                                                Config.GET_SHOP_INFO)['shop_id']
                                            ?.toString();
                                String itemNumId =
                                    goods['default_item_num_id']?.toString();
                                String styleNumId =
                                    goods['style_num_id']?.toString();
                                String ecStyleNumId =
                                    goods['ec_style_num_id']?.toString();
                                logic.requestAddGoods(ecShopNumId, itemNumId,
                                    styleNumId, ecStyleNumId);
                              }
                            }
                          },
                          child: Image.asset(
                            'assets/images/add_shopping_cart.png',
                            width: 20,
                            height: 20,
                            color: !soldOutBool
                                ? Color(0xffEA5504)
                                : Color(0xffcccccc),
                          ),
                        )
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _playRulesWidget() {
    final Icon icon = Icon(
      Icons.chevron_right,
      size: 20,
      color: const Color(0xff999999),
    );
    return Container(
      color: white,
      padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '超级团玩法',
            style: TextStyle(fontSize: 16),
          ),
          Container(
            margin: const EdgeInsets.only(top: 12),
            padding: const EdgeInsets.only(top: 12),
            decoration: BoxDecoration(
              color: white,
              border: Border(
                top: BorderSide(color: const Color(0xffefefef)),
              ),
            ),
            child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  _rules(data: '参团', index: '1'),
                  icon,
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      _rules(data: '以当前超级团', index: '2'),
                      Text(
                        '最低价格支付',
                        style: TextStyle(height: 1.3),
                      )
                    ],
                  ),
                  icon,
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      _rules(data: '成团后按成团', index: '3'),
                      Text(
                        '人数支付差价',
                        style: TextStyle(height: 1.3),
                      )
                    ],
                  ),
                ]),
          ),
        ],
      ),
    );
  }

  Widget _playRulesjtjWidget(){
    if (state.details==null||state.details['price_list']==null) {
      return Container();
    }
    List jtj = state.details['price_list'];
    // people_count   、   price
    final Icon icon = Icon(
      Icons.chevron_right,
      size: 20,
      color: const Color(0xff999999),
    );
    return Container(
      color: white,
      padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children:[
          Text(
            '超级团阶梯价',
            style: TextStyle(fontSize: 16),
          ),
          GestureDetector(
            onTap: () {
              Get.toNamed(RouteConfig.jietijia, arguments: {
                "jietijia":jtj
              });
            },
            child:Container(
            margin: const EdgeInsets.only(top: 12),
            padding: const EdgeInsets.only(top: 12),
            decoration: BoxDecoration(
              color: white,
              border: Border(
                top: BorderSide(color: const Color(0xffefefef)),
              ),
            ),
            child: Row(
              mainAxisSize:MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    width: 250,
                    child: Column(
                    mainAxisSize:MainAxisSize.max,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Row(
                        mainAxisSize:MainAxisSize.max,
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text('参团${jtj[0]["people_count"]}人'),
                          Text('成交价为${jtj[0]["price"]}元'),
                        ],
                      ),
                      Container(
                        height: 10,
                      ),
                      Row(
                        mainAxisSize:MainAxisSize.max,
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text('参团大于等于${jtj[1]["people_count"]}人'),
                          Text('成交价为${jtj[1]["price"]}元'),
                        ],
                      ),
                    ],
                  ),
                  ),
                  icon,
                ]
              ),
            )
          ),
        ]
      ),
    );
  }

  // 图文详情
  Widget richTextDetailLayout() {
    if (state.richText == null ||
        state.richText.toString().isEmpty ||
         state.richText['wap_desc'] == null ||
         state.richText['wap_desc'].toString().isEmpty
        ) {
      return Container(
        key: _richContentLayoutKey,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Padding(
              padding: const EdgeInsets.only(left: 10, top: 15, bottom: 10),
              child: Text(
                '图文详情',
                style: TextStyle(
                  fontSize: 16,
                  color: const Color(0xFF222222),
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
          ],
        ),
      );
    }
    return Container(
      key: _richContentLayoutKey,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: const EdgeInsets.only(left: 10, top: 15, bottom: 10),
            child: Text(
              '图文详情',
              style: TextStyle(
                fontSize: 16,
                color: const Color(0xFF222222),
                fontWeight: FontWeight.w500,
              ),
            ),
          ),

          // 商品详情头部广告
          // state.advertising.length > 0
          //     ? Container(
          //         margin: EdgeInsets.only(right: 20.w, left: 20.w),
          //         child: Column(
          //           children: _newList(state.advertising, 0),
          //         ),
          //       )
          //     : Container(),
          //  state.richText == null ||state.richText['head_desc'] == null?Container():Html(data: state.richText['head_desc'].toString()),
          // 图文详情头部
          // Html(data: state.richText['head_desc'].toString()),
          _detailHeader(),
          // // 图文详情中部
          // // Html(data: state.richText['wap_desc'].toString()),
          _detailWapDesc(),
          // 图文详情尾部
          // Html(data: state.richText['end_desc'].toString()),
          _detailEndDesc(),
          // 商品详情尾部广告
          // state.advertising.length > 0
          //     ? Container(
          //         margin: EdgeInsets.only(right: 20.w, left: 20.w),
          //         child: Column(
          //           children: _newList(state.advertising, 2),
          //         ),
          //       )
          //     : Container(),
        ],
      ),
    );
  }

  // 图文详情头部
  Widget _detailHeader() {
    if (state.richText == null ||
        state.richText.toString().isEmpty ||
        state.richText['head_desc'] == null ||
        state.richText['head_desc'].toString().isEmpty) {
      return Container();
    }
    print(state.richText['head_desc'].toString());
    return Html(data: state.richText['head_desc']);
  }

  // 图文详情中部
  Widget _detailWapDesc() {
    if (state.richText == null ||
        state.richText.toString().isEmpty ||
        state.richText['wap_desc'] == null ||
        state.richText['wap_desc'].toString().isEmpty) {
      return Container();
    }
    return Html(data: state.richText['wap_desc'].toString());
  }

  // 图文详情尾部
  Widget _detailEndDesc() {
    if (state.richText == null ||
        state.richText.toString().isEmpty ||
        state.richText['end_desc'] == null ||
        state.richText['end_desc'].toString().isEmpty) {
      return Container();
    }
    return Html(data: state.richText['end_desc'].toString());
  }


  String constructTime(num mss) {
    int days = (mss / (60 * 60 * 24)).floor();
    int hours = ((mss % (60 * 60 * 24)) / (60 * 60)).floor();
    int minutes = ((mss % (60 * 60)) / 60).floor();
    int seconds = (mss % 60).floor();
    return days.toString() +
        "天" +
        hours.toString() +
        "时" +
        minutes.toString() +
        "分" +
        seconds.toString() +
        "秒";
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }
  
}
